package com.sheepjin.design_pattern.创建型模型.工厂模式;

import com.sheepjin.design_pattern.创建型模型.工厂模式.intf.Shape;
import com.sheepjin.design_pattern.创建型模型.工厂模式.intf.ShapeFactory;

/**
 * @author： SheepJin
 * @date： 2022/6/2 - 22:06
 * @description：
 * @modifiedBy：
 */
public class FactoryPatternDemoTest {

    public static void main(String[] args) {

        System.out.println("单例对象方式：");
        Shape shape = ShapeFactory.ShapeFactoryUtils.getShapeByShapeCode(ShapeFactory.ShapeFactoryUtils.CIRCLE.shapeCode);
        System.out.println(shape);
        shape.drawOneShape();

        Shape shape3 = ShapeFactory.ShapeFactoryUtils.getShapeByShapeCode(ShapeFactory.ShapeFactoryUtils.CIRCLE.shapeCode);
        System.out.println(shape3);
        shape3.drawOneShape();

        Shape shape2 = ShapeFactory.ShapeFactoryUtils.getShapeByShapeCode(ShapeFactory.ShapeFactoryUtils.DIAMOND.shapeCode);
        System.out.println(shape2);
        shape2.drawOneShape();

        System.out.println("---------------------------------");

        System.out.println("非单例对象方式：");
        Shape shapeByShapeClass1 = ShapeFactory.SHAPEUTILS.getShapeByShapeClass(ShapeFactory.SHAPEUTILS.CIRCLE.shapeClass);
        Shape shapeByShapeClass2 = ShapeFactory.SHAPEUTILS.getShapeByShapeClass(ShapeFactory.SHAPEUTILS.CIRCLE.shapeClass);
        Shape shapeByShapeClass3 = ShapeFactory.SHAPEUTILS.getShapeByShapeClass(ShapeFactory.SHAPEUTILS.DIAMOND.shapeClass);
        System.out.println(shapeByShapeClass1);
        shapeByShapeClass1.drawOneShape();
        System.out.println(shapeByShapeClass2);
        shapeByShapeClass2.drawOneShape();
        System.out.println(shapeByShapeClass3);
        shapeByShapeClass3.drawOneShape();

    }

}
